home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
pascal
/
tpb4_src.zip
/
UTILMNU2.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1988-09-13
|
12KB
|
458 lines
{ TPBoard 4.2 Copyright (c) 1987,88 by Jon Schneider & Rick Petersen
Portions Copyright (c) 1986,87 by Steve Fox and Les Archambault
Last modified :: 5-12-88 1:22 am
}
{$R-} {Range checking off}
{$B-} {Boolean complete evaluation off}
{$S-} {Stack checking off}
{$I+} {I/O checking on}
{$N-} {No numeric coprocessor}
Unit Utilmnu2;
Interface
Uses
TPCrt, Dos, Globals, Core1,
Core2, TPSTRING, TPDOS, Dirs;
procedure show_user_stats;
procedure get_protocol;
procedure get_old_password(pr : StrPr; var valid : Boolean);
procedure get_new_password;
procedure get_case;
procedure get_nulls;
procedure get_phone;
procedure graphics_on;
procedure graphics_off;
{==========================================================================}
Implementation
procedure show_user_stats;
var
Str : StrTAD;
proto : StrPr;
time_on,
time_left,
time_today,
time_total : Integer;
dollars : Real;
begin
Seek(logr_file, 0);
Read(logr_file, logr_rec);
Str := FormTAD(login_t);
WriteLn(Com);
WriteLn(Com, 'Login : ', Str);
if user_rec.access >= val_acc then
Write(Com, 'Validated User : ')
else
Write(Com, 'Non-Validated User: ');
WriteLn(Com, user_rec.fn, ' ', user_rec.ln);
WriteLn(Com);
timer(time_on, time_left);
time_today := user_rec.time_today+time_on;
time_total := user_rec.time_total+time_on;
WriteLn(Com, 'Caller number : ', logr_rec.user);
WriteLn(Com, 'Access time today : ', time_today);
WriteLn(Com, 'Access time total : ', time_total);
Str := FormTAD(user_rec.laston);
WriteLn(Com, 'Last on system : ', Str);
WriteLn(Com, 'Last high message : ', user_rec.lasthi);
Write(Com, 'Uploads to date : ', user_rec.upload);
case CreditType of
Points :
WriteLn(Com, ' (# of Points )');
Kilobytes :
WriteLn(Com, ' (# of Kilobytes)');
Files :
WriteLn(Com);
end;
WriteLn(Com, 'Downloads to date : ', user_rec.download);
Write(Com, 'Ratio allowed : ');
if user_rec.ratio = 0 then
WriteLn(Com, 'Unlimited')
else
WriteLn(Com, user_rec.ratio, ' to 1');
dollars := (Int(user_rec.acct_bal)/100);
WriteLn(Com, 'Account balance : $', dollars:4:2);
case user_rec.protocol of
'X' :
proto := 'Xmodem CRC';
'Y' :
proto := 'Ymodem';
'B' :
proto := 'Ymodem Batch';
'Z' :
proto := 'Zmodem';
'C' :
proto := 'Xmodem Checksum';
'Q' :
proto := 'Ymodem G (Qmodem)';
'O' :
proto := 'Xmodem OverThruster';
'G' :
proto := 'Ymodem G';
end;
WriteLn(Com, 'Default protocol : ', proto);
WriteLn(Com);
if cmd_tail and (time_left = (time_to_event-time_on)) then
WriteLn(Com, BEL, BEL, BEL,
'Your time limit on this call has been adjusted for an upcoming event.');
WriteLn(Com);
end;
procedure get_protocol;
var
prompt_str : StrStd;
begin
repeat
WriteLn(Com);
if AllowMNP then
prompt_str := 'Default protocol <X><C><Y><B><Z><G><Q><O><?>'
else
prompt_str := 'Default protocol <X><C><Y><B><Z><O><?>';
st := prompt(prompt_str, 80, 'ES?M');
if Length(st) = 1 then
ch := st[1]
else
ch := '?';
if ch in ['X', 'C', 'Y', 'B', 'Z', 'G', 'Q', 'O'] then
begin
user_rec.protocol := ch;
WriteLn(Com);
WriteLn(Com, 'You can override your default by appending the desired protocol');
WriteLn(Com, 'letter to the ''S'' or ''R'' commands, i.e. ''SZ'' for ''Send Zmodem''.');
end
else
begin
WriteLn(Com);
WriteLn(Com, 'X - Xmodem CRC');
WriteLn(Com, 'C - Xmodem Checksum');
WriteLn(Com, 'Y - Ymodem (Xmodem 1k)');
WriteLn(Com, 'B - Ymodem Batch (True Ymodem)');
WriteLn(Com, 'Z - Zmodem');
if AllowMNP then
WriteLn(Com, 'G - Ymodem G Batch');
if AllowMNP then
WriteLn(Com, 'Q - Ymodem G (Qmodem compatible)');
WriteLn(Com, 'O - Xmodem OverThruster');
end
until (not Online) or (ch in ['X', 'C', 'Y', 'B', 'Z', 'G', 'Q', 'O']);
end;
procedure get_old_password(pr : StrPr;
var valid : Boolean);
{ Accept and validate old password. Only 'Max_Tries' will be allowed. }
var
tries : Integer;
begin
tries := 0;
repeat
valid := (user_rec.pw = prompt(pr, len_pw, 'S'));
Inc(tries)
until (not Online) or valid or (tries = max_tries);
if not valid then
WriteLn(Com, 'Only ', max_tries, ' tries allowed.')
end;
procedure get_new_password;
{ Accept and validate new password. }
var
i, x : Integer;
trial_pw : password;
begin
WriteLn(Com);
WriteLn(Com, 'Please select and enter a password of 4-', len_pw, ' characters');
WriteLn(Com, 'to ensure that no one else uses your name on the system.');
WriteLn(Com);
repeat
repeat
trial_pw := prompt('Password (will NOT display as you type)', len_pw, 'SL');
i := Length(trial_pw);
if (i < 4) or (i > len_pw) then
WriteLn(Com, 'Length must be 4-', len_pw, ' characters.')
else
begin
for x := 1 to Length(trial_pw) do
if (not(Ord(trial_pw[x]) in [33..90])) then
i := 0;
if i = 0 then
WriteLn(Com, 'Only ASCII text characters allowed.');
end;
until (not Online) or ((4 <= i) and (i <= len_pw));
user_rec.pw := prompt(' Please enter it again for verification', len_pw, 'SL');
if user_rec.pw <> trial_pw then
WriteLn(Com, 'No match. Try again.')
until (not Online) or (user_rec.pw = trial_pw);
WriteLn(Com);
WriteLn(Com, 'Please remember your password.');
WriteLn(Com, 'It will be required for all future calls.')
end;
procedure get_case;
{ Get case switch from user }
begin
user_rec.shift_lock := not ask('Can your terminal display lower case', 'Y')
end;
procedure get_nulls;
{ Get nulls from user }
begin
if Online then
user_rec.nulls := strint(prompt('How many [0-99] nulls do you need? [Usually 0] ', 2, 'ES'))
end;
procedure get_phone; { Get phone number from user }
var
digits : Byte;
Str : string[12];
procedure check_number;
var
OK, error : Boolean;
i : Integer;
test_ph : string;
bad_numbers : Text;
begin
with user_rec do
begin
OK := False;
i := 1;
test_ph := ph;
repeat
Delete(test_ph, Pos('-', test_ph), 1);
until (Pos('-', test_ph) = 0);
repeat
ch := test_ph[i];
if (ch <> test_ph[Succ(i)]) then
OK := True;
Inc(i);
until OK or (i = 10);
if (Pos('800', test_ph) = 1) then
OK := False;
Delete(test_ph, 1, 3);
if (Pos('555', test_ph) = 1) or (Pos('911', test_ph) = 1) then
OK := False;
if OK and ExistFile('BADNUMS.LST') then
begin
Assign(bad_numbers, 'BADNUMS.LST');
Reset(bad_numbers);
repeat
{$I-}
ReadLn(bad_numbers, test_ph) {$I+} ;
error := (IoResult <> 0);
if ph = test_ph then
OK := False;
until EOF(bad_numbers) or (not OK) or error;
Close(bad_numbers)
end;
if (not OK) then
begin
Log(19, 'Phone');
Write(Com, BEL);
for i := 1 to 12 do
Write(Com, BS, ' ', BS);
ph := '';
digits := 0
end;
end;
end;
begin
with user_rec do
begin
ph := '';
if format then
begin
Write(Com, 'Your phone number [###-###-####] > ');
digits := 0;
repeat
ch := GetChar;
if ch in ['0'..'9'] then
begin
Write(Com, ch);
ph := ph+ch;
Inc(digits);
end
else if (ch in [RUB, BS]) and (digits > 0) then
begin
Write(Com, BS, ' ', BS);
if (digits = 4) or (digits = 8) then
begin
Write(Com, BS, ' ', BS);
ph[0] := Chr(Pred(Ord(ph[0])));
Dec(digits)
end;
Dec(digits);
ph[0] := Chr(Pred(Ord(ph[0])));
end
else if (not(ch in ['-', NUL, RUB, BS, CR])) then
begin
Write(Com, ch);
Write(Com, BEL);
Write(Com, BS, ' ', BS)
end;
if (digits in [3, 7]) then
begin
Write(Com, '-');
Inc(digits);
ph := ph+'-'
end;
if Length(ph) = 12 then
check_number;
until (Length(ph) = 12) or (not online);
WriteLn(Com);
end
else
begin
Str := prompt('Your phone number', len_ph, 'EL');
if Str <> '' then
ph := Str;
end;
end;
end;
procedure clear_sysm_heap;
var
thisS : SysmPtr;
begin
while SysmBase <> nil do { Delete out system msg linked list }
begin
thisS := SysmBase;
SysmBase := SysmBase^.next; { Go to next on chain }
Dispose(thisS) { Reclaim space }
end;
end;
procedure make_index;
var
i : Integer;
SysmThis,
SysmLast : SysmPtr;
begin
i := 0;
SysmBase := nil;
Reset(sysm_file);
Read(sysm_file, sysm_rec);
while not EoF(sysm_file) do
begin
if sysm_rec[1] = ':' then
begin
New(SysmThis);
if SysmBase = nil then
SysmBase := SysmThis
else
SysmLast^.next := SysmThis;
SysmLast := SysmThis;
SysmLast^.key := sysm_rec[2];
SysmLast^.loc := i;
SysmLast^.next := nil;
end;
Read(sysm_file, sysm_rec);
Inc(i);
end;
end;
procedure clear_colors;
begin
hi := '';
low := '';
green := '';
yellow := '';
cyan := '';
white := '';
end;
procedure graphics_on;
var
temp : Str72;
begin
Close(sysm_file);
Assign(sysm_file, sysmg_name+ext);
clear_sysm_heap;
make_index;
graphics := True;
temp := question;
temp := StUpcase(temp);
if Pos('COLOR', temp) <> 0 then
begin
hi := ESC+'[1m';
low := ESC+'[0m';
green := ESC+'[32m';
yellow := ESC+'[33m';
cyan := ESC+'[36m';
white := ESC+'[37m';
end
else
clear_colors;
end;
procedure graphics_off;
begin
Close(sysm_file);
Assign(sysm_file, sysm_name+ext);
clear_sysm_heap;
make_index;
graphics := False;
clear_colors;
end;
end. { of UTILMNU2.PAS }